1. Field of the Invention
This invention relates to a cache system for effecting a cache operation for an external storage device such as a magnetic disk device, an opto-magnetic disk device or a floppy disk device capable of exchanging a storage medium (recording medium). More particularly, the present invention relates to a cache system which prevents transfer of wrong cache data to a CPU (Central Processing Unit) even when a storage medium is exchanged, and which updates automatically and sequentially the content of a data block, etc., stored in the cache memory to the content of the storage medium after the exchange.
2. Description of the Related Art
First of all, a structural example of a cache system according to the prior art will be explained with reference to FIGS. 1(a) and 1(b) of the accompanying drawings in order to have the conventional cache system more easily understood.
FIG. 1(a) is a block diagram useful for explaining the principle of a cache system for a conventional external storage device. A host 1 includes a CPU 2, a main memory 3, a cache memory 4, a cache control unit 5 and a cache management table 6.
FIG. 1(b) conceptually shows an example of the content of the cache management table 6. This cache management table 6 stores a storage position of a data block, which is stored in the cache memory 4, in the external storage device, that is, a device number allocated to the external storage device, a storage position represented by a logical address comprising a cylinder number, a head number and a sector number in the external storage device, and an area number of the cache memory 4 storing this data block in the corresponding way.
When the CPU 2 sends a read instruction for reading out data and a program (hereinafter called merely the "data") stored in the external storage device 9 to the cache control unit 5, this cache control unit 5 looks up the cache management table 6 on the basis of the logical address such as the cylinder number, the sector number, the head number, etc., of the external storage device, for example, and retrieves whether or not the data block containing the data requested by the CPU 2 is stored in the cache memory 4.
If the storage of the required data in the cache memory 4 is identified (or is "hit"), the cache control unit 5 reads out this data by the logical address read out from the cache management table 6 of the cache memory 4, and returns it to the CPU 2. Accordingly, the data stored in the external storage device 9 can be supplied within a short time to the CPU 2 without causing a read delay such as a waiting time (latency time) for positioning of the read head of the external storage device or for the start of revolution of the head. As a result, the processing time can be remarkably reduced as a whole.
When the data block containing the required data is not stored (is not "hit") as a result of retrieval of the cache management table 6 by the cache control unit 5 described above, the data block containing the required data is read out from the external storage device 9 and is supplied to the CPU 2.
Incidentally, the data thus read out is also stored in the cache memory 4 and at the same time, the logical address of the external storage device, from which the data is read out, is registered in the cache management table 6 in such a manner as to correspond to the area number of the cache memory storing this data block, as shown in FIG. 1(b), so that the cache function can be utilized at the time of the next read request.
In this case, if an empty memory area capable of storing the data read out from the external storage device does not exist in the cache memory, a purging process is executed for the data of the cache blocks first written into the cache memory in order to secure a space for writing a new data block, and the data block which is read out afresh and is to be cached is written into this space. This purging process is usually referred to as an LRU (least recently used) process in a computer system.
However, the conventional cache system described above uses the device number of the external storage device and the logical address on the storage medium of this external storage device as the data for designating the data block stored in the cache memory. Accordingly, when the storage medium of the external storage devices is exchanged, the data stored in the memory area corresponding to the area number of the cache memory obtained by the logical address is the data read out from the storage medium before the exchange even if the result of retrieval of the cache management table by the read instruction for the memory medium after the exchange hits and consequently, the data which is different from the data instructed by the read instruction for the storage medium after the exchange is transferred to the CPU.